{% extends 'base_with_listing.html' %}

{% block title %}User reservations{% endblock %}

{% block header %} {% if reader %} {{ reader.first_name }} {{ reader.last_name }} {% else %}User reservations {% endif %}{% endblock %}

{% block header_row %}
    <th>
        Send
    </th>
    <th>ID</th>
    <th>Status</th>
    <th>Title</th>
    <th>Authors</th>
    <th>From</th>
    <th>To</th>
    <th>Location</th>
    {% if can_cancel %}
        <th></th>
    {% endif %}
{% endblock %}

{% block order %} [[5,0]] {% endblock %}

{% block item_row %}
    <td> 
        <form action='.' method='post'>
            {% if row.can_rent %} 
                <input type='hidden' name='rent' value='{{ row.id }}'>
                <input type='submit' name='action' value='Rent' {% if row.rental_impossible %} disabled='disabled' {% endif %}>
            {% else %}
                {% if row.shipment_requested %}
                    Shipment requested
                {% else %}
                    <input type='hidden' name='send' value='{{ row.id }}'>
                    <input type='submit' name='action' value='Send me'> {# {% if row.rental_impossible %} disabled='disabled' {% endif %}> #}
                {% endif %}
            {% endif %} 
        </form>
    </td>
    <td>
        <b><a href="{% url copy_one row.reservation.book_copy.id %}">{{ row.reservation.book_copy.shelf_mark }}</a></b>
    </td> <td>
        {% firstof row.rental_impossible "Ready" %}
    </td> <td>
        <a href="{% url book_one row.reservation.book_copy.book.id %}">{{ row.title }}</a>
    </td> <td>
        {{ row.authors|join:', ' }}
    </td> <td>
        {{ row.from_date }}
    </td> <td>
        {{ row.to_date }}
    </td> <td>
        <a href="{% url location_one row.reservation.book_copy.location.id %}">{{ row.reservation.book_copy.location }}</a>
    </td>
    {% if can_cancel %}
        <td>
            <form action='.' method='post'>
                <input type='hidden' name='cancel' value='{{ row.id }}'>
                <input type='submit' name='action' value='Cancel'>
            </form>
        </td>
    {% endif %}
{% endblock %}


{% block after_table %}
        <div class="inner_menu">
          <ul>
            <li><a href='archive/'>Show archival reservations</a></li>
            <li><a href='new/'>Rent something else</a></li>
            <li><a href='{{ cancel_all_url }}'>Cancel all reservations</a></li>
          </ul>
        </div>
{% endblock %}

